import React, { Component } from 'react';
import {
    StyleSheet,
    Text,
    View
} from 'react-native';

export default class LifecycleComponent extends Component {
    constructor(props){
        super(props);
        console.log('---constructor---')
        this.state = {
            count: 0
        }
    }
    componentWillMount(){
        console.log('---componentWillMount---')
    }
    componentDidMount(){
        console.log('---componentDidMount---')
    }
    componentWillReceivePops(nextProps){
        console.log('---componentWillReceivePops---')
    }
    shouldComponentUpdate(nextProps, nextState){
        console.log('---shouldComponentUpdate---')
        return true;
    }
    componentWillUpdate(nextProps, nextState){
        console.log('---componentWillUpdate---')
    }
    componentDidUpdate(prevProps, prevState){
        console.log('---componentDidUpdate---')
    }
    componentWillUnmount(){
        console.log('---componentWillUnmount---')
    }

    render(){
        return <View>
            <Text
                style={{fontSize:20,backgroundColor:'red'}}
                onPress={()=>{
                    this.setState({
                        count:this.state.count+1
                    })
                }}
            >有本事你打我呀.
                <Text style={{fontSize:20}}>被打了{this.state.count}次</Text>
                </Text>
        </View>

    }
}